<?php

namespace longhu\services;

use Predis\Client;
use think\Service;

class RedisService extends Service
{
    public function register()
    {
        // 单独配置PRedis
        $this->app->bind('predis', function () {
            $config = config('redis.predis');
            return new Client($config);
        });
       // 使用连接池配置PRedis
        $this->app->bind('predis_pool', function () {
            $poolConfig = config('redis.predis_pool');
            $predis = new Client($poolConfig['parameters'], $poolConfig['options']);
            return $predis->getConnection()->getPool();
        });
    }
}